#include<stdlib.h>
#include<string.h>

int bullle_sort(void *arr, int num, int size, int (*cmp)(const void *, const void *)){
	int i, j;
	void *t = malloc(size);
	for(i = 0; i < num; i++){
		for(j = 0; j < num -i -1; j++){
			if(cmp((char *)arr + size * j,(char *)arr + size * (j+1)) > 0){
				memcpy(t, (char *)arr + size * j, size);
				memcpy((char *)arr + size * j, (char *)arr + size * (j + 1), size);
				memcpy((char *)arr + size * (j + 1), t, size);
			}
		}
	}
	free(t);
	t = NULL;
}


void show_arr(void *arr, int num, int size, void (*pri)(const void *)){
	char *arr1 = (char *)arr;
	for(int i = 0; i < num; i++){
		pri(arr1 + i * size);
	}
}



